package com.example.scaffold;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 应用程序入口类
 * 遵循阿里手册：类名使用UpperCamelCase风格，必须遵从驼峰形式
 *
 * @author example
 */
@Slf4j
@SpringBootApplication
@EnableCaching
public class ScaffoldApplication {

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(ScaffoldApplication.class, args);
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String contextPath = env.getProperty("server.servlet.context-path", "");
        
        log.info("\n----------------------------------------------------------\n\t" +
                "Application '{}' is running! Access URLs:\n\t" +
                "Local: \t\thttp://localhost:{}{}\n\t" +
                "External: \thttp://{}:{}{}\n\t" +
                "Doc: \thttp://{}:{}{}/doc.html\n" +
                "----------------------------------------------------------",
            env.getProperty("spring.application.name"),
            port, contextPath,
            ip, port, contextPath,
            ip, port, contextPath);
    }
}
    